import Vue from "vue"
import axios from "axios"
import VueAxios from "vue-axios"
import Qs from "qs"

Vue.prototype.baseUrl = "/api"

if (process.env.NODE_ENV === "production") {
  Vue.prototype.baseUrl = "http://hishishi.top:8000"
}

Vue.prototype.$get = function (api, data) {
  if (data === undefined) {
    data = {}
  }
  var ox = axios.get(this.baseUrl + api, { params: data })
  return ox
}
Vue.prototype.$post = function (api, data) {
  data = Qs.stringify(data)
  var ox = axios.post(this.baseUrl + api, data)
  return ox
}

Vue.use(VueAxios, axios)
